<%@ page language="java" pageEncoding="UTF-8"%>
<%@include file="/global/global-head.jsp" %>
<!DOCTYPE html>
<html lang="zh">
<head>
    <title>吉车惠后台管理系统</title>
    <%@include file="/global/global-other.jsp" %>

    <script type="text/javascript">
        var $sys_admin_login_list = new Object();
        var $sys_admin_login_list_Datagrid;
        var $sys_admin_login_list_toolbar = [{
                text:'<i class="fa fa-search" aria-hidden="true"></i>刷新',
                handler:function(){
                    $sys_admin_login_list.reload();
                }
            },'-',
            {
                text:'<i class="fa fa-lock" aria-hidden="true"></i>锁定',
                handler:function(){
                    $sys_admin_login_list.lock();
                }
            },
            {
                text:'<i class="fa fa-unlock-alt" aria-hidden="true"></i>取消锁定',
                handler:function(){
                    $sys_admin_login_list.unlock();
                }
            },'-',{
                text:'<i class="fa fa-users" aria-hidden="true"></i>角色授权',
                handler:function(){
                    $sys_admin_login_list.roleGrant();
                }
            }
        ];
        $(function(){
            //gird 初始化
            $sys_admin_login_list_Datagrid = $('#sys_admin_login_list_Datagrid').datagrid({
                filterBtnIconCls:'icon-filter',
                queryParams: {
                    "filter_EQ_a.delete_status": '0',
                    "filter_NEQ_p.no": 'admin'
                },
                pageSize : 20,
                remoteFilter:true
            });

            $sys_admin_login_list_Datagrid.datagrid('enableFilter', [
                {field:'lockStatus',type:'label'},
                {field:'manageClassify',type:'label'},
                {field:'lastLoginAt',type:'label'},
                {field:'createAt',type:'label'},
                {field:'t',type:'label'}
            ]);


        });

        //刷新
        $sys_admin_login_list.reload = function(){
            $sys_admin_login_list_Datagrid.datagrid('reload');
        };

        //锁定
        $sys_admin_login_list.lock = function (){
            var row = $sys_admin_login_list_Datagrid.datagrid('getSelected');
            if(row==null){
                parent.$.messager.alert("提示",errMsg("请选择一行数据！"),"error");
            }else{
                parent.$.messager.confirm('提示','是否要锁定姓名【'+row.name+'】？',function(flag){
                    if (flag){
                        $.post('${ctx}/sys/admin/lock?_m=exec', {adminId : row.adminId}, function(json) {
                            if(statusMsg(json)){
                                parent.$.messager.alert("提示","锁定成功！","info",function(){
                                    $sys_admin_login_list_Datagrid.datagrid('reload');
                                });
                            }
                        }, "JSON");
                    }
                });
            }
        }

        //取消锁定
        $sys_admin_login_list.unlock = function (){
            var row = $sys_admin_login_list_Datagrid.datagrid('getSelected');
            if(row==null){
                parent.$.messager.alert("提示",errMsg("请选择一行数据！"),"error");
            }else if(row.lockStatus=='0'){
                parent.$.messager.alert("提示",errMsg("登录用户未锁定，不能取消操作！"),"error");
            }else{
                parent.$.messager.confirm('提示','是否要锁定姓名【'+row.name+'】？',function(flag){
                    if (flag){
                        $.post('${ctx}/sys/admin/unlock?_m=exec', {adminId : row.adminId}, function(json) {
                            if(statusMsg(json)){
                                parent.$.messager.alert("提示","取消成功！","info",function(){
                                    $sys_admin_login_list_Datagrid.datagrid('reload');
                                });
                            }
                        }, "JSON");
                    }
                });
            }
        }

        //角色授权
        $sys_admin_login_list.roleGrant = function (){
            var row = $sys_admin_login_list_Datagrid.datagrid('getSelected');
            if(row==null){
                parent.$.messager.alert("提示",errMsg("请选择一行数据！"),"error");
            }else{
                viewDialog = parent.$.dialog({
                    title: '<i class="fa fa-th-large"></i><span class="dialog-title">&nbsp;角色授权<span>',
                    href: '${ctx}/sys/admin/role?_m=init&adminId='+row.adminId+'&r='+Math.random(),
                    width: 900,
                    height: 440,
                    modal: true,
                    onClose : function() {
                        $(this).dialog('destroy');
                    },
                    buttons:[{
                        text:'<i class="fa fa-floppy-o" aria-hidden="true"></i>保存',
                        width:'70px',
                        handler:function(){
                            viewDialog.find('iframe').get(0).contentWindow.submitForm(viewDialog);
                        }
                    },{
                        text:'<i class="fa fa-reply" aria-hidden="true"></i>返回',
                        width:'70px',
                        handler:function(){
                            viewDialog.dialog('destroy');
                        }
                    }]
                });
            }
        }
    </script>
</head>
<body>
<div class="easyui-layout" data-options="fit:true">
    <div data-options="region:'center',border:false">
        <table id="sys_admin_login_list_Datagrid"  style="width:100%;height:100%"
               data-options="border:false,rownumbers:true,autoRowHeight:false,singleSelect:true,pagination:true,sortName:'createAt',sortOrder:'desc',toolbar:$sys_admin_login_list_toolbar,rowStyler: function(index,row){return {style:'height:30px'};},url:'${ctx}/sys/admin/search?_m=load',method:'post'">
            <thead>
            <tr>
                <th data-options="field:'account',width:120,align:'center'">账号</th>
                <th data-options="field:'name',width:150,align:'center'">姓名</th>
                <th data-options="field:'manageClassify',width:120,align:'center',formatter:
                    function(value,row,index){
                        if(row.manageClassify=='01'){
                            return '超级管理员';
                        }else if(row.manageClassify=='02'){
                            return '普通管理员';
                        }else if(row.manageClassify=='03'){
                            return '业务人员';
                        }else{
                            return '';
                        }
                    }
                ">管理身份</th>
                <th data-options="field:'lockStatus',width:150,align:'center',formatter:
                    function(value,row,index){
                        if(row.lockStatus=='0'){
                            return '未锁定';
                        }else if(row.lockStatus=='1'){
                            return '<span style=\'color:red\'>锁定</span>';
                        }else{
                            return '';
                        }
                    }
                ">锁定状态</th>
                <th data-options="field:'lastLoginAt',width:150,align:'center'">最后一次登录时间</th>
                <th data-options="field:'createAt',width:150,align:'center'">添加时间</th>
                <th data-options="field:'t',width:20,align:'center'"></th>
            </tr>
            </thead>
        </table>
    </div>
</div>
</body>
</html>